package com.gxa.login.controller;

import com.gxa.login.service.ForgetPwdService;
import dto.ResultDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import param.ForgetParam;

import javax.annotation.Resource;

@RestController
@RequestMapping("/forget")
@Api(tags = "忘记密码接口")
public class ForgetPwdController {

    @Resource
    private ForgetPwdService forgetPwdService;


    @ApiOperation(value = "忘记密码接口")
    @PostMapping("/password")
    @ApiImplicitParams({
            @ApiImplicitParam(name="email",value="邮箱必填",required = true),
            @ApiImplicitParam(name="newPwd",value="新密码必填",required = true),
            @ApiImplicitParam(name="code",value="验证码必填",required = true)
    })
    public ResultDTO forgetPwd(@RequestBody ForgetParam forgetParam){
        return forgetPwdService.forgetPwd(forgetParam);
    }

    @ApiOperation(value = "忘记密码发送邮件接口")
    @PostMapping("/sendEmail")
    @ApiImplicitParams({
            @ApiImplicitParam(name="email",value="邮箱必填",required = true)
    })
    public ResultDTO sendEmail(@RequestBody ForgetParam forgetParam){
        return forgetPwdService.sendEmail(forgetParam);
    }
}
